import { reqAddressInfo, reqOrderInfo } from "@/api";
import { Promise } from "core-js";

const state = {
    addressInfo: [],
    orderInfo:{}
};
const mutations = {
    GETUSERADDRESS(state, value) {
        state.addressInfo = value;
    },
    GETORDERINFO(state, value){
        state.orderInfo=value
    }
};
const actions = {
    async getUserAddress({ commit }) {
        let result = await reqAddressInfo();
        if (result.code == 200) {
            commit('GETUSERADDRESS', result.data);
            return 'ok'
        }else{
            return Promise.reject(new Error(result.message))
        }
    },
    async getOrderInfo({ commit }) {
        let result = await reqOrderInfo();
        if (result.code == 200) {
            commit('GETORDERINFO', result.data);
            return 'ok'
        }else{
            return Promise.reject(new Error(result.message))
        }
    }
};
const getters = {

};

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}